<template>
  <div style="width:100%;overflow:hidden">
    <weui-navbar :list="navbar_list" :index="navbar_index" @on-click="onNavbarClick">
      <router-view></router-view>
    </weui-navbar>
  </div>
</template>

<script>
import WeuiNavbar from '../components/WeuiNavbar'

export default {
  components: {
    WeuiNavbar
  },
  data() {
    return {
	  navbar_list: [
	    'url',
	    /*'shopping',
		'music'*/
	  ],
	  link_list: [
	    '/add/url',
		'/add/shopping',
		'/add/music'
	  ],
	  navbar_index: 0,
	}
  },
  methods: {
    onNavbarClick(index) {
	  this.navbar_index = index
	  this.$router.redirect(this.link_list[index])
	}
  },
  mounted() {
    const link = location.hash.substring(1)
	this.link_list.forEach((item, index) => {
	  if(item.indexOf(link) == 0)
	    this.navbar_index = index
	})
  }
}
</script>